package com.test.diaocha;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class DetailActivity extends AppCompatActivity {

    Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);
        intent = getIntent();
        if(intent == null) {
            finish();
            return;
        }

        setText(R.id.nameTxt, "name");
        setText(R.id.dateTxt, "date");
        setText(R.id.sexTxt, "sex");
        setText(R.id.departmentTxt, "department");
        setText(R.id.phoneTxt, "phone");
        setText(R.id.yesOrNoTxt, "yesOrNo");
        setText(R.id.adviseTxt, "advise");
    }

    private void setText(int id, String text) {
        ((TextView) findViewById(id)).setText(intent.getStringExtra(text));
    }
}